package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.ActionLog;

@Repository
public interface ActionLogDao extends JpaRepository<ActionLog, Integer>, JpaSpecificationExecutor<ActionLog> {

	@Query("from ActionLog where actionPath = ?1")
	List<ActionLog> find(String name);

	@Query("from ActionLog where actionPath like ?1")
	List<ActionLog> findLike(String name);

	@Query(value = "select * from ActionLog limit ?, ?", nativeQuery = true)
	List<ActionLog> findPage(Integer offset, Integer size);

	@Query(value = "select * from ActionLog where actionPath = ? limit ?, ?", nativeQuery = true)
	List<ActionLog> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from ActionLog where actionPath like ? limit ?, ?", nativeQuery = true)
	List<ActionLog> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from ActionLog where actionPath = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from ActionLog where actionPath like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from ActionLog order by id asc")
	List<ActionLog> findAllAsc();
}

